【Git】Git 版本管理 ( 补充提交版本 git commit |
您所在的位置:网站首页 › git checkout 清空 › 【Git】Git 版本管理 ( 补充提交版本 git commit |
文章目录一、补充提交版本 git commit --amend二、版本库提取文件 git checkout -- filename三、删除文件 git rm一、补充提交版本 git commit --amend 修改 file1.txt 和 file2.txt 两个文件 ; 执行 git add file1.txt命令 , 添加 file1.txt 文件到 暂存区 ; 然后执行 git commit -m "modify file1 and 2"命令 , 提交版本库 ; 此时使用 git status 命令 , 查询当前状态 , 发现有一个文件遗漏了 ; 此时执行 git add file2.txt提交文件到暂存区 , 然后执行 git commit --amend命令 , 补充提交到版本库 , 期间会弹出 vim 编辑器 , 编辑要提交的说明 , 再次使用 git status 查询 , 发现提交成功 ; 二、版本库提取文件 git checkout – filenamegit checkout -- filename 命令的作用是 , 从版本库中取出 filename 对应的文件 , 然后使用该文件覆盖当前的 filename 文件 ; 将 file1.txt 文件进行修改 , 第二行添加一排感叹号 , 但是不添加暂存区 , 也不提交到版本库 ; 执行 git checkout -- file1.txt命令 , 会从版本库中取出最近一次提交的 file1.txt 文件 , 并使用该文件覆盖当前目录的 file1.txt 文件 ; 注意 , 该操作会覆盖掉当前的 filename 文件 , 如果当前 filename 文件有改动 , 但是没有提交 , 一旦执行该命令 , 该文件就会永久被删除 ; 三、删除文件 git rm将 file3.txt 文件删除 , 先执行 git rm file3.txt命令 , 删除该文件 , 然后执行 git commit -m "remove file3.txt"命令 , 将删除文件信息提交到 版本库 ; 执行过程 : D:\Git\git-learning-course>git rm file3.txt rm 'file3.txt' D:\Git\git-learning-course>git commit -m "remove file3.txt" [master d74ada0] remove file3.txt 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 file3.txt D:\Git\git-learning-course> |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |